import React, { Component } from 'react';
import {setDocumentTitle} from '../utils';

/**
 * 分享设备
 */
class ShareDevice extends Component {

    constructor(props, context) {
        super(props, context);
        let ticket = '';
        if (this.props.location && this.props.location.pathname) {
            let array = this.props.location.pathname.split(':');
            ticket = array[array.length - 1].replace('/', '');
        }
        this.width = document.documentElement.clientWidth / 5 * 3;
        this.state = {
            ticket: ticket,
        }
    }
    componentDidMount() {
        setDocumentTitle('分享设备');
    }

    render() {
        return (
            <div>
                <div
                    style={{
                        width: '100%',
                        height: '100%',
                        zIndex: 1,
                        position: 'absolute',
                        background: '#000000',
                        opacity: 0.9
                    }}>
                </div>
                <div style={{
                    position: 'absolute',
                    zIndex: 2,
                    display: 'flex',
                    flexDirection: 'column',
                    width: '100%',
                    height: '100%',
                    justifyContent: 'center',
                    alignItems: 'center'
                }}>
                    <img src={'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' + this.state.ticket}
                        style={{ width: this.width, height: this.width }} alt='' />
                    <div style={{ color: 'white', marginTop: '16px', fontSize: '13px' }}>扫描二维码或长按分享给家人</div>
                </div>
            </div>
        );
    }
}


export default ShareDevice;